package com.wx.mapper;

import com.wx.common.MyMapper;
import com.wx.domain.dto.RoleDto;
import com.wx.entity.SysRole;
import com.wx.entity.SysUser;
import com.wx.entity.SysUserRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;


@Mapper
@Component
public interface SysUserRoleMapper extends MyMapper<SysUserRole> {

    /**
     * <p>Title:      queryOwnRoles. </p>
     * <p>Description 根据userId查询拥有的角色信息</p>
     *
     * @param query the query
     * @return list list
     * @Author <a href="xinglinglove1029@163.com"/>杨文生</a>
     * @since 2018 /2/8 14:50
     */
    List<RoleDto> queryOwnRoles(SysUserRole query);

    /**
     * <p>Title:     getBindUserByRoleId. </p>
     * <p>Description 根据角色编号查询绑定的用户信息</p>
     *
     * @param roleId the role id
     * @return bind user by role id
     * @Author <a href="xinglinglove1029@163.com"/>杨文生</a>
     * @since 2018 /4/28 14:57
     */
    List<SysUser> getBindUserByRoleId(String roleId);

    /**
     * <p>Title:      getRoleList. </p>
     * <p>Description 查詢当前用户所绑定的角色信息</p>
     *
     * @return userId String
     * @Author        <a href="xinglinglove1029@163.com"/>杨文生</a>
     * @since     2019/4/11 14:35
     */
    List<SysRole> getBindRoleListByUserId(String userId);

    /**
     * <p>Title:      deleteByUserId. </p>
     * <p>Description 刪除用戶和角色的關係</p>
     *
     * @param       userId   String
     * @return
     * @Author        <a href="xinglinglove1029@163.com"/>杨文生</a>
     * @since     2019/4/11 17:06
     */
    int deleteByUserId(String userId);

    /**
     * <p>Title:      batchDeleteByRoleId. </p>
     * <p>Description 根据角色id删除用户，并且排除超级管理员</p>
     *
     * @param      roleId   String
     * @return
     * @Author        <a href="xinglinglove1029@163.com"/>杨文生</a>
     * @since     2019/6/18 10:13
     */
    int batchDeleteByRoleId(@Param("roleId") String roleId);


    List<SysUser> getBindUserByRoleIds(@Param("roleIds") List<String> roleIds);

    List<SysUserRole> getBindRoleByRoleId(String roleId);
}